SUMMARY = "OP-TEE examples"
DESCRIPTION = "Open Portable Trusted Execution Environment - Sample Applications"
HOMEPAGE = "https://gitee.com/phytium_embedded/phytium-optee"

LICENSE = "BSD-2-Clause"
LIC_FILES_CHKSUM = "file://../LICENSE;md5=f8763dcaa37e97f694f27de555a39537"

DEPENDS = "optee-phytium-client optee-os-tadevkit  python3-cryptography-native"

SRC_URI:append = " \
    file://0001-app-add-Makfile.patch \
"
inherit python3native
require optee.inc

EXTRA_OEMAKE += "TA_DEV_KIT_DIR=${TA_DEV_KIT_DIR} \
                 HOST_CROSS_COMPILE=${HOST_PREFIX} \
                 TA_CROSS_COMPILE=${HOST_PREFIX} \
                 OUTPUT_DIR=${B} \
               "

S = "${WORKDIR}/git/app"
B = "${WORKDIR}/build"


do_compile() {
    oe_runmake -C ${S}
}
do_compile[cleandirs] = "${B}"

do_install () {
    mkdir -p ${D}${nonarch_base_libdir}/optee_armtz
    mkdir -p ${D}${bindir}
    mkdir -p ${D}${libdir}/tee-supplicant/plugins
    install -D -p -m0755 ${B}/ca/* ${D}${bindir}
    install -D -p -m0444 ${B}/ta/* ${D}${nonarch_base_libdir}/optee_armtz
}

FILES:${PN} += "${nonarch_base_libdir}/optee_armtz/ \
                ${libdir}/tee-supplicant/plugins "

# Imports machine specific configs from staging to build
PACKAGE_ARCH = "${MACHINE_ARCH}"
INSANE_SKIP:${PN} += "ldflags"
